package com.cn.thread.disruptor.chain.publish;

import com.cn.thread.disruptor.domain.Trade;
import com.cn.thread.disruptor.chain.translate.TradeEventTranslator;
import com.lmax.disruptor.dsl.Disruptor;

import java.util.concurrent.CountDownLatch;

public class TradePublish implements Runnable{

    private Disruptor<Trade> disruptor;
    private CountDownLatch latch;

    public TradePublish(CountDownLatch latch, Disruptor<Trade> disruptor) {
        this.disruptor = disruptor;
        this.latch = latch;
    }
    @Override
    public void run() {
        TradeEventTranslator eventTranslator = new TradeEventTranslator();
        //新的提交任务的方式
        disruptor.publishEvent(eventTranslator);
        latch.countDown();
    }
}
